return type
The typename field in function declarations is optional. Functions that return an
XLONG value or no value do not have to specify a return type. Type-suffixes other
than $ are not valid on function names, so typename is needed on functions that do not
return XLONG or no value (or STRING with $ suffix).
function definition
A function definition is the code that executes when a function is called, and includes
everything from the FUNCTION statement through the next END FUNCTION statement.
FUNCTION statements have the following syntax:
FUNCTION [typename] FuncName([arglist]) [default-typename]
default type
The data type of variables not typed by type-suffixes or variable type declaration
statements become the default type, which is XLONG.
function arguments
If a function takes no arguments, a right parenthesis must follow the left parenthesis
(separable only by whitespace). Otherwise a comma separated list of arguments is
placed between the parentheses. The data type of each argument is specified in one
of the following ways:
typename plus argument name --- XLONG x, DOUBLE ddd
argument name with type-suffix --- n!, bend#, name$
any of these followed by [] --- SINGLE j[], name$[]
RETURN and EXIT FUNCTION
RETURN and EXIT FUNCTION statements cause the same action as END FUNCTION , except any
number of these statements can be used in each function, they need not start a source
line, and they may appear within block structures. RETURN and EXIT FUNCTION are often used
within decision blocks like IF and SELECT CASE.
The syntax of RETURN and EXIT FUNCTION are:
RETURN [expression]
EXIT FUNCTION [expression]
END FUNCTION
END FUNCTION statements mark the end of function definitions and have have the following
syntax:
END FUNCTION [expression]
END FUNCTION marks the end of function and causes execution to return to the function that
called it. The value of the expression following END FUNCTION is returned by the
function, or, if there is no expression, zero or null-string is returned.